package logrus

import "github.com/sirupsen/logrus"

func RunLogrus() {
	config := LogrusConfig{
		//文件路径(包含文件名)
		Filename:  "D:/tmp/logs/go.log",
		Formatter: &MyFormatter{},
		Level:     logrus.InfoLevel,
		//显示文件名和行号
		ReportCaller: true,
		//日志文件轮转时间(秒) 1天
		RotationTime: 60 * 60 * 24,
		//日志文件存活时间,超期则删除
		FileMaxAge: 60 * 60 * 24 * 30,
	}

	InitLogs(&config)

	//WithFields 加固定参数
	logger1 := logrus.WithFields(logrus.Fields{
		"animal": "walrus",
		"size":   10,
	})
	logger1.Info("A group of walrus emerges from the ocean")
	logger1.Infof("A group of walrus emerges from the ocean,  %d",1000)

	logger2 :=logrus.WithFields(logrus.Fields{
		"omg":    true,
		"number": 122,
	})
	logger2.Warn("The group's number increased tremendously!")

	logger3 := logrus.WithFields(logrus.Fields{
		"omg":    true,
		"number": 100,
	})
	logger3.Fatal("The ice breaks!")
}
